import cv2
import numpy as np


img = cv2.imread("face1.jpg", cv2.IMREAD_UNCHANGED)
cv2.imshow('original', img)
soft = 5
detail = 3
alpha = 0.7
img_g = cv2.bilateralFilter(img, soft * 5, soft * 12.5, soft * 12.5)
cv2.imshow('bilateralFilter', img_g)

bilatera = img - cv2.bilateralFilter(img, soft * 5, soft * 12.5, soft * 12.5) + 128
highpass = cv2.GaussianBlur(bilatera, (2 * detail - 1, 2 * detail - 1), 0)
cv2.imshow('highpass', highpass)
img = np.int16(img)
img_g = np.int16(img_g)
highpass = np.int16(highpass)
tmp1 = img_g + 2 * highpass - 255
tmp1 = cv2.addWeighted(img_g, alpha,tmp1, 1 - alpha, 0)
#tmp1 = img + 2 * highpass - 255
tmp1 = np.uint8(np.clip(tmp1, 0, 255))
print(tmp1.dtype)
cv2.imshow('dist',tmp1)

#tmp2 = np.uint8(np.clip(tmp2, 0, 255))
#cv2.imshow('tmp2', tmp2)

#tmp2 = cv2.addWeighted(img_g, alpha, tmp1, 1 - alpha, 0)
#tmp2 = np.uint8(np.clip(tmp2, 0, 255))
#cv2.imshow('tmp2', tmp2)
# dst = np.uint8(np.clip(tmp2 + 10, 0, 255))
# dst = np.uint8(np.clip(tmp2 + 1, 0, 255))
#img1 = np.hstack((img, tmp1))
#img2 = np.hstack((tmp2, dst))
#img = np.vstack((img1, img2))
#cv2.imshow('soft skin', img)


cv2.waitKey(0)
cv2.destroyAllWindows()